﻿@using EmployeeLeaveSystem.Shared;
@using EmployeeLeaveSystem.Shared.Models;
@inject IMessageService _MessageService;
@inject HttpClient _HttpClient;
@using ESM=EmployeeLeaveSystem.Shared.Models;
@inject ModalService _modalService;

<Table DataSource="listWOMHistroy" TItem="ESM.AddWOM">
    <PropertyColumn Property="c=>c.Id" />
    <PropertyColumn Property="c=>c.Created" />
    <PropertyColumn Property="c=>c.Reason" />
    <PropertyColumn Property="c=>c.Type" Title="类型">
        @if (context.Type == AddWOMType.工作日加班) {
                <div>工作日加班</div>
        } else if (context.Type == AddWOMType.周末加班) {
                <div>周末加班</div>
        } else {
                <div>节假日加班</div>
        }
    </PropertyColumn>
    <PropertyColumn Property="c=>c.AcceptStaff.Name" Title="审核人" />
    <PropertyColumn Property="c=>c.AcceptTag" />
    <ActionColumn>
        <Button OnClick="()=>{OpenModalShow(context.Id);}">查看</Button>
    </ActionColumn>
</Table>

@code {
    List<ESM.AddWOM> listWOMHistroy = new();
    protected override async Task OnInitializedAsync() {
        listWOMHistroy = await _HttpClient.GetFromJsonAsync<List<ESM.AddWOM>>($"api/OverTime/GetOverTime?usrId={GobalManager.myInfo?.Id}");
        _MessageService.Success("加载成功");
    }
    private async Task OpenModalShow(int Id) {
        var modalConfig = new ModalOptions {
                    Title = "详情",
                    Draggable = true,
                    Footer = null,
                    Maximizable = true,
                    Width = "80vw",
                    Content = @<ViewWOMManager Id="Id" />
        };

        await _modalService.CreateModalAsync(modalConfig);
    }
}
